<?php

/*Author: Panos Sakkos */

class Entity
{
	var $id;
	var $name;
	var $category_id;
	var $attributes;
	var $activated;

	function __construct()
	{
		$this->id = -1;
		$this->category_id = -1;
		$this->name = "";
		$this->activated = 0;
	}

	/* Mutators */

	function SetId($id)
	{
		$this->id = $id;
	}

	function SetName($name)
	{
		$this->name = $name;
	}

	function SetCategoryId($category_id)
	{
		$this->category_id = $category_id;
	}

	function SetAttributes($attributes)
	{
		$this->attributes = $attributes;
	}

	function SetActivated($value)
	{
		$this->activated = $value;
	}

	/* Accessors */

	function GetId()
	{
		return $this->id;
	}

	function GetName()
	{
		return $this->name;
	}

	function GetCategoryId()
	{
		return $this->category_id;
	}

	function GetAttributes()
	{
		return $this->attributes;
	}

	function GetActivated()
	{
		return $this->activated;
	}

	function SetValueToAttribute($value, $attribute)
	{
		for($i = 0; $i < count($this->attributes); $i++)
		{
			if( strcmp($this->attributes[$i]->GetName(), $attribute) == 0)
			{
				$this->attributes[$i]->SetValue($value);
				break;
			}
		}
	}

	function SetIdToAttribute($id, $attribute)
	{
		for($i = 0; $i < count($this->attributes); $i++)
		{
			if( strcmp($this->attributes[$i]->GetName(), $attribute) == 0)
			{
				$this->attributes[$i]->SetId($id);
				break;
			}
		}
	}
	
}

?>
